package com.mjl.shops.adapter;

import android.view.View;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mjl.shops.R;
import com.mjl.shops.base.ShopApp;
import com.mjl.shops.bean.CollectionBean;
import com.mjl.shops.utils.StringUtils;

import java.util.List;

public class CollectionAdapter extends BaseQuickAdapter<CollectionBean, BaseViewHolder> {

    private boolean isSelect;

    public CollectionAdapter(int layoutResId, @Nullable List<CollectionBean> data) {
        super(layoutResId, data);
        isSelect = false;
    }

    public void setShowSelect(boolean t){
        this.isSelect = t;
    }

    @Override
    protected void convert(BaseViewHolder helper, CollectionBean item) {

        if (isSelect){
            helper.getView(R.id.select_icon).setVisibility(View.VISIBLE);
        }else{
            helper.getView(R.id.select_icon).setVisibility(View.GONE);
        }

        if (StringUtils.strEmpty(item.getName())){
            helper.setText(R.id.goods_name_tv,item.getName());
        }else{
            helper.setText(R.id.goods_name_tv,"");
        }

        if (item.getPrice()>0){
            helper.setText(R.id.price_tv,"¥"+ ShopApp.decimalFormat.format(item.getPrice()));
        }else{
            helper.setText(R.id.price_tv,"¥0.00");
        }

        if (item.getPay_person_num()>0){
            helper.setText(R.id.pay_person_num_tv,item.getPay_person_num()+"人已付款");
        }else{
            helper.setText(R.id.pay_person_num_tv,"");
        }

    }
}
